<?php include("config.php"); ?>
<?php include("fonctions.php"); ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Document sans nom</title>
</head>


<form method="post" enctype="multipart/form-data" target="_self" >
	<label>nom du menu : </label><input type="text" name="nom_menu" /><br />
	<label>image du menu : </label><input type="file" name="image_menu" /><br />
  	<label>nom de la page : </label><input type="text" name="adresse_menu" /><br />
    <input type="submit" value="Ajouter" name="ajout" />

</form>




<body>
</body>
</html>

<?php 

if(isset($_POST["ajout"]))
{
	if($_POST["nom_menu"] != "" && $_POST["adresse_menu"] != "")
	{
		if($_FILES["image_menu"]['name'] == "")
			$image = "";
		else
		{
			$image = "images/menu/".$_FILES["image_menu"]['name'];
		}
		
		$image = upload();
		
		connect();
		//$bdd = $GLOBALS['bdd'];
		$req = $bdd->prepare('INSERT INTO menu(libelle_menu, image_menu, adresse_menu) VALUES(:nom, :image, :adresse)');
		$req->execute(array(
							'nom' => $_POST["nom_menu"],
							'image' => $image,
							'adresse' => $_POST["adresse_menu"],
						));
						echo "menu ajouté<br />";
		
	}
}

?>

